import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';

export default (appInfo: EggAppInfo) => {
  const config = {} as PowerPartial<EggAppConfig>;

  // override config from framework / plugin
  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1643939771659_2394';

  // add your egg config in here
  config.sequelize = {
    dialect:'postgres',
    host:'127.0.0.1',
    port:5432,
    password:'Xh123pswd',
    username:'postgres',
    database:'iotbase',
  };

  config.jwt = {
    secret: "_iotbase@zw",//自定义 token 的加密条件字符串
    enable: true,
    ignore: [ '/api/v1/test/', '/public/','/iotBAPI/user/login' ], // 哪些请求不需要认证
  };
  
  config.cors = {
    origin:'*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH'
  };


  config.middleware = [];

  // add your special config in here
  const bizConfig = {
    sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`,
  };

  // the return config will combines to EggAppConfig
  return {
    ...config,
    ...bizConfig,
  };
};
